Terminal终端美化(Oh My Posh) 您所在的位置:网站首页 oh my posh编码 Terminal终端美化(Oh My Posh)

Terminal终端美化(Oh My Posh)

#Terminal终端美化(Oh My Posh)| 来源: 网络整理| 查看: 265

安装Oh My Posh

可以先去Microsofe Store 安装winget,会比较方便

winget install JanDeDobbeleer.OhMyPosh 复制代码

安装完:

会在C:\Users\自己用户名\AppData\Local\Programs\oh-my-posh\themes>有很多主题

预览所有主题命令 Get-PoshThemes 复制代码

image-20220426123111651

初始化并应用主题 oh-my-posh --init --shell pwsh --config "自己的安装目录\oh-my-posh\themes\schema.json" | Invoke-Expression #schema.json ---- 选择themes目录下的一款主题文件 复制代码 分隔符乱码问题

但会发现分隔符会有乱码的问题

乱码问题解决方式:

安装Nerd Fonts字体,在Terminal>Power Shell选择自己安装的字体,保存重启就生效啦。

PS:刚开始以为没有我常用的JetBrain Mono字体,就没在意这种解决方案,没想到里面字体挺丰富.

配置PowerShell

因为应用的主题只在当前窗口有效果,所以需要配置每次PowerShell启动时都会执行应用主题的脚本

1.打开配置文件方式一 获取到PowerShell配置文件绝对路径 $PROFILE 复制代码

image-20220426124525580

找到这个文件位置,打开并添加需要Power Shell启动时执行的脚本,保存文件重新打开Terminal看效果 oh-my-posh --init --shell pwsh --config "自己的安装目录\oh-my-posh\themes\schema.json" | Invoke-Expression 复制代码 2.打开配置文件方式二

如果安装了VS Code,如下命令可以直接打开Power Shell配置文件

code $PROFILE 复制代码 自定义主题

可借鉴的up主题文件:gitee.com/NilTor/publ…

更多配置可查看官网配置文档

VS Code终端配置

没有配置打开VS Code终端报错:

The term 'oh-my-posh' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify | that the path is correct and try again. 复制代码 在环境变量新增Oh My Posh路径下bin目录

image-20220426141214178

在设置中配置配置自己安装的Nerd Font终端字体,(这里我填上我安装的是JetBrainsMono Nerd Font Mono)

image-20220426141358102

隐藏提示语

每次打开都会有这四句提示语,想要打开是干干净净的界面。

image-20220426233405476

在PowerShell配置项中添加一个配置 ,配置参数 -NoLogo为隐藏提示语

"commandline": "自己的pwsh.exe的路径 -NoLogo", 复制代码

完整配置参考

{ "colorScheme": "Campbell", "font": { "face": "JetBrainsMono Nerd Font Mono" }, "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell", "source": "Windows.Terminal.PowershellCore", "commandline": "C:\\Program Files\\WindowsApps\\Microsoft.PowerShell_7.2.2.0_x64__8wekyb3d8bbwe\\pwsh.exe -NoLogo", "startingDirectory": null 复制代码

image-20220426233614912



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有